package ${packageBase}.${tableBean.tableNameNoDash}.service;


import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.PageRequest;
import org.springframework.transaction.annotation.Transactional;

import ${packageBase}.${tableBean.tableNameNoDash}.dao.${tableBean.tableNameCapitalized}Dao;
import ${packageBase}.${tableBean.tableNameNoDash}.entity.${tableBean.tableNameCapitalized}Entity;

/**
*${tableBean.tableNameCapitalized} service
*/
@Transactional(readOnly=true)
@Service("${tableBean.tableNameNoDash}Service")
public class ${tableBean.tableNameCapitalized}Service {
   	private Log log = LogFactory.getLog(this.getClass());
	@Autowired
	private ${tableBean.tableNameCapitalized}Dao  ${tableBean.tableNameNoDash}Dao;

  
  	@Transactional(readOnly=false,transactionManager="jpaTransactionManager")
    public ${tableBean.tableNameCapitalized}Entity save(${tableBean.tableNameCapitalized}Entity ${tableBean.tableNameNoDash}){
    	return ${tableBean.tableNameNoDash}Dao.save(${tableBean.tableNameNoDash});
    }
    @Transactional(readOnly=false,transactionManager="jpaTransactionManager")
    public List<${tableBean.tableNameCapitalized}Entity> save(List<${tableBean.tableNameCapitalized}Entity> ${tableBean.tableNameNoDash}s){
    	return ${tableBean.tableNameNoDash}Dao.save(${tableBean.tableNameNoDash}s);
    }
	
    public ${tableBean.tableNameCapitalized}Entity get(long id) {
    	return ${tableBean.tableNameNoDash}Dao.findOne(id);
    }
     /**
     * 删除
     * @param dream
     */
	@Transactional(readOnly=false,transactionManager="jpaTransactionManager")
    public void delete(long id) {
   	 	${tableBean.tableNameNoDash}Dao.delete(id);
    }
    /**
     * 所有列表
     */
    public List<${tableBean.tableNameCapitalized}Entity> getAll() {
    	return ${tableBean.tableNameNoDash}Dao.findAll();
    }
    /**
     * 分页列表
     * @param page
     * @return
     */
    public Page<${tableBean.tableNameCapitalized}Entity> getListOfPage(Pageable pageRequest){
    	return ${tableBean.tableNameNoDash}Dao.findAll(pageRequest);
    }
}
